package com.ansion.baseui.base;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

/**
 * created by zhaoyuntao
 * on 29/12/2020
 * description:
 */
public abstract class TPresenterProxy<T extends TBasePresenter<?>, A extends TVPBaseActivity<T>> {
    private final T t;

    public TPresenterProxy(T t) {
        this.t = t;
    }

    @SuppressWarnings("unchecked")
    @NonNull
    final protected A getView() {
        return (A) t.getView();
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    final public <Proxy extends TPresenterProxy> Proxy getProxy(Class<Proxy> clazz) {
        return (Proxy) t.getProxy(clazz);
    }

    @SuppressWarnings("unchecked")
    @Nullable
    final protected A getLifeCircle() {
        return (A) t.getLifeCircle();
    }

    @NonNull
    final protected T getPresenter() {
        return t;
    }

    final protected void runUI(Runnable runnable) {
        getPresenter().runUI(0, runnable);
    }

    final protected void runIO(Runnable runnable) {
        getPresenter().runIO(runnable);
    }

    final protected void runUI(long mills, Runnable runnable) {
        getPresenter().runUI(mills, runnable);
    }

    protected void onRegisterListeners() {
    }

    protected void onUnregisterListeners() {
    }

    protected void onRegisterBroadcast(@NonNull List<BroadcastProcessor> processors, @NonNull List<String> categories) {

    }
}
